<?php

add_action( 'after_setup_theme', 'nvr_setup' );

if ( ! function_exists( 'nvr_setup' ) ):

function nvr_setup() {

	// This theme styles the visual editor with editor-style.css to match the theme style.
	add_editor_style();

	// This theme uses post thumbnails
	if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
		add_theme_support( 'post-thumbnails' );
		add_theme_support( 'woocommerce' );
		add_image_size( 'blog-post-image', 770, 370, true ); // Blog Image
		add_image_size( 'post-thumb', 100, 100, true ); // Recent Post Widget Image
		add_image_size( 'testimonial-thumb', 100, 100, true ); // Testimonial Image
		add_image_size( 'portfolio-image', 700, 394, true ); // Portfolio Image Original
		add_image_size( 'portfolio-image-square', 700, 700, true ); // Portfolio Image Square
		add_image_size( 'portfolio-image-portrait', 700, 9999, true ); // Portfolio Image Portrait
		add_image_size( 'portfolio-image-landscape', 700, 394, true ); // Portfolio Image Landscape
	}

	// Add default posts and comments RSS feed links to head
	add_theme_support( 'automatic-feed-links' );
	
	// This theme supports a variety of post formats.
	add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'gallery', 'video', 'audio' ) );
	
	// Removing the sidebar in woocommerce
	remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
	/* 270x330 16px 11px 16px 11px*/
	/*remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );*/

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus( array(
		'mainmenu' => __( 'Main Menu', THE_LANG )
	) );
	register_nav_menus( array(
		'secondarymenu' => __( 'Secondary Menu', THE_LANG )
	) );
	
	//function for woocommerce customization
	nvr_woocommerce();
}
endif;

function exceptation(){
	add_theme_support( 'custom-header' );
	add_theme_support( 'custom-background' );
}

/***** START - All functions for woocommerce customization *****/
function nvr_woocommerce(){
	add_filter('woocommerce_show_page_title', 'nvr_woocommerce_show_page_title');
	add_filter('woocommerce_breadcrumb_defaults', 'nvr_woocommerce_breadcrumb_defaults');
	remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb' , 20);
	remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
	
	add_action( 'woocommerce_after_single_product_summary', 'nvr_woocommerce_upsell_display', 15 );
	add_filter( 'woocommerce_output_related_products_args', 'nvr_woocommerce_output_related_products_args' );
	
}

function nvr_woocommerce_show_page_title(){
	return false;
}

function nvr_woocommerce_breadcrumb_defaults(){
	return array(
		'delimiter'   => ' &nbsp;&#47;&nbsp; ',
		'wrap_before' => '<nav class="nvr-breadcrumb" itemprop="breadcrumb">',
		'wrap_after'  => '</nav>',
		'before'      => '',
		'after'       => '',
		'home'        => _x( 'Home', 'breadcrumb', 'woocommerce' ),
	);
}

function nvr_woocommerce_output_related_products_args() {
  global $product;
	
	$args = array(
		'posts_per_page' => 3,
		'columns' => 3,
		'orderby' => 'rand'
	);
	return $args;
}

function nvr_woocommerce_output_related_products(){
	woocommerce_related_products( 3, 3 );
}

function nvr_woocommerce_upsell_display(){
	woocommerce_upsell_display( 4, 4);
}
/***** END - All functions for woocommerce customization *****/

/***** START - All functions, hooks, and filters for simple share buttons customization *****/
remove_filter( 'the_content', 'show_share_buttons');	
remove_filter( 'the_excerpt', 'show_share_buttons');
/***** END - All functions, hooks, and filters for simple share buttons customization *****/